<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_id')->index()->comment('订单号');
            $table->string('single_number')->nullable()->comment('快递单号（付款成功更新）');
            $table->string('send_mobile')->nullable()->comment('寄件人手机号');
            $table->string('to_mobile')->nullable()->comment('收件人手机号');
            $table->string('take_code')->nullable()->comment('取件码');
            $table->unsignedInteger('uid')->nullable()->comment('用户id');
            $table->unsignedInteger('courier_id')->nullable()->comment('取件快递员id');
            $table->unsignedInteger('express_id')->comment('快递公司ID');
            $table->unsignedInteger('service_id')->index()->comment('服务站ID');
            $table->unsignedInteger('network_id')->nullable()->comment('网点ID');
            $table->unsignedInteger('shipper_id')->nullable()->comment('收发件信息ID');
            $table->unsignedTinyInteger('status')->default(1)->comment('1.暂存  2.配送中，3.待取件，4.已取件，5.投诉中，6.异常件，7.已退回 ，8.已退款');
            $table->string('label')->nullable()->default("")->comment('标签');
            $table->unsignedTinyInteger('type')->default(1)->comment('0.派送件  1.自提件，2.寄送件');
            $table->string('position')->nullable()->comment('位置');
            $table->unsignedTinyInteger('pay_status')->default(1)->comment('1.未支付，2.现金，3.微信');
            $table->timestamp('pay_time')->nullable()->comment('支付时间');
            $table->text('send_info')->nullable()->comment('寄件人信息');
            $table->text('to_info')->nullable()->comment('收件人信息');
            $table->string('entry_courier')->nullable()->comment('入库人');
            $table->timestamp('sign_in_at')->nullable()->comment('签收时间');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order');
    }
}
